From c4e31ace4d84aa275a857dc60e9ddf6a1fb41339 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 4 Apr 2005 05:15:32 +0000 Subject: [PATCH] Allow completion popups to be wider than the entry. (#131916, Ross Burton) 2005-04-04 Matthias Clasen Allow completion popups to be wider than the entry. (#131916, Ross Burton) * gtk/gtkentrycompletion.[hc]: Add a boolean popup-set-width property. * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): Don't force the popup to have the same width as the entry if popup-set-width is FALSE. * gtk/gtk.symbols: Add new functions. --- ChangeLog | 13 +++++ ChangeLog.pre-2-10 | 13 +++++ ChangeLog.pre-2-8 | 13 +++++ docs/reference/ChangeLog | 4 ++ docs/reference/gtk/gtk-sections.txt | 2 + gtk/gtk.symbols | 5 ++ gtk/gtkentrycompletion.c | 82 ++++++++++++++++++++++++++++- gtk/gtkentrycompletion.h | 4 ++ 8 files changed, 134 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05e369f8db..f49110102c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-04-04 Matthias Clasen + + Allow completion popups to be wider than the entry. (#131916, + Ross Burton) + + * gtk/gtkentrycompletion.[hc]: Add a boolean popup-set-width property. + + * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): + Don't force the popup to have the same width as the entry if + popup-set-width is FALSE. + + * gtk/gtk.symbols: Add new functions. + 2005-04-04 Matthias Clasen * gtk/gtkactiongroup.c (gtk_action_group_add_action_with_accel): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 05e369f8db..f49110102c 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +2005-04-04 Matthias Clasen + + Allow completion popups to be wider than the entry. (#131916, + Ross Burton) + + * gtk/gtkentrycompletion.[hc]: Add a boolean popup-set-width property. + + * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): + Don't force the popup to have the same width as the entry if + popup-set-width is FALSE. + + * gtk/gtk.symbols: Add new functions. + 2005-04-04 Matthias Clasen * gtk/gtkactiongroup.c (gtk_action_group_add_action_with_accel): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 05e369f8db..f49110102c 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,16 @@ +2005-04-04 Matthias Clasen + + Allow completion popups to be wider than the entry. (#131916, + Ross Burton) + + * gtk/gtkentrycompletion.[hc]: Add a boolean popup-set-width property. + + * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): + Don't force the popup to have the same width as the entry if + popup-set-width is FALSE. + + * gtk/gtk.symbols: Add new functions. + 2005-04-04 Matthias Clasen * gtk/gtkactiongroup.c (gtk_action_group_add_action_with_accel): diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index d706a5b281..0566aaf890 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +2005-04-04 Matthias Clasen + + * gtk/gtk-sections.txt: Add new functions. + 2005-04-01 Matthias Clasen * gtk/tmpl/gtkselection.sgml: Move docs inline. diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 7d31817f9b..26871b4c62 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -1119,6 +1119,8 @@ gtk_entry_completion_set_inline_completion gtk_entry_completion_get_inline_completion gtk_entry_completion_set_popup_completion gtk_entry_completion_get_popup_completion +gtk_entry_completion_set_popup_set_width +gtk_entry_completion_get_popup_set_width GTK_TYPE_ENTRY_COMPLETION GTK_ENTRY_COMPLETION diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 4bee95dd78..02ccc6ecca 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -1104,6 +1104,7 @@ gtk_entry_completion_get_inline_completion gtk_entry_completion_get_minimum_key_length gtk_entry_completion_get_model gtk_entry_completion_get_popup_completion +gtk_entry_completion_get_popup_set_width gtk_entry_completion_get_text_column gtk_entry_completion_get_type G_GNUC_CONST gtk_entry_completion_insert_action_markup @@ -1115,6 +1116,7 @@ gtk_entry_completion_set_match_func gtk_entry_completion_set_minimum_key_length gtk_entry_completion_set_model gtk_entry_completion_set_popup_completion +gtk_entry_completion_set_popup_set_width gtk_entry_completion_set_text_column #endif #endif @@ -1652,12 +1654,15 @@ gtk_icon_theme_set_search_path_utf8 #if IN_FILE(__GTK_ICON_VIEW_C__) gtk_icon_view_get_column_spacing gtk_icon_view_get_columns +gtk_icon_view_set_cursor +gtk_icon_view_get_cursor gtk_icon_view_get_item_width gtk_icon_view_get_margin gtk_icon_view_get_markup_column gtk_icon_view_get_model gtk_icon_view_get_orientation gtk_icon_view_get_path_at_pos +gtk_icon_view_get_item_at_pos gtk_icon_view_get_pixbuf_column gtk_icon_view_get_row_spacing gtk_icon_view_get_selected_items diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index dd06d71747..403cf35c4d 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -58,7 +58,8 @@ enum PROP_MINIMUM_KEY_LENGTH, PROP_TEXT_COLUMN, PROP_INLINE_COMPLETION, - PROP_POPUP_COMPLETION + PROP_POPUP_COMPLETION, + PROP_POPUP_SET_WIDTH }; #define GTK_ENTRY_COMPLETION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ENTRY_COMPLETION, GtkEntryCompletionPrivate)) @@ -334,6 +335,22 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass) TRUE, GTK_PARAM_READWRITE)); + /** + * GtkEntryCompletion:popup-set-width: + * + * Determines whether the completions popup window will be + * resized to the width of the entry. + * + * Since: 2.8 + */ + g_object_class_install_property (object_class, + PROP_POPUP_SET_WIDTH, + g_param_spec_boolean ("popup-set-width", + P_("Popup set width"), + P_("If TRUE, the popup window will have the same size as the entry"), + TRUE, + GTK_PARAM_READWRITE)); + g_type_class_add_private (object_class, sizeof (GtkEntryCompletionPrivate)); } @@ -365,6 +382,7 @@ gtk_entry_completion_init (GtkEntryCompletion *completion) priv->has_completion = FALSE; priv->inline_completion = FALSE; priv->popup_completion = TRUE; + priv->popup_set_width = TRUE; /* completions */ priv->filter_model = NULL; @@ -494,6 +512,10 @@ gtk_entry_completion_set_property (GObject *object, priv->popup_completion = g_value_get_boolean (value); break; + case PROP_POPUP_SET_WIDTH: + priv->popup_set_width = g_value_get_boolean (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -531,6 +553,10 @@ gtk_entry_completion_get_property (GObject *object, g_value_set_boolean (value, gtk_entry_completion_get_popup_completion (completion)); break; + case PROP_POPUP_SET_WIDTH: + g_value_set_boolean (value, gtk_entry_completion_get_popup_set_width (completion)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1293,7 +1319,12 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion) GTK_WIDGET (completion->priv->entry)->window); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); - width = MIN (completion->priv->entry->allocation.width, monitor.width) - 2 * x_border; + if (completion->priv->popup_set_width) + width = MIN (completion->priv->entry->allocation.width, monitor.width) - 2 * x_border; + else + width = -1; + + gtk_tree_view_columns_autosize (completion->priv->tree_view); gtk_widget_set_size_request (completion->priv->tree_view, width, items * height); /* default on no match */ @@ -1610,5 +1641,52 @@ gtk_entry_completion_get_popup_completion (GtkEntryCompletion *completion) return completion->priv->popup_completion; } +/** + * gtk_entry_completion_set_popup_set_width: + * @completion: a #GtkEntryCompletion + * @popup_set_width: %TRUE to make the width of the popup the same as the entry + * + * Sets whether the completion popup window will be resized to be the same + * width as the entry. + * + * Since: 2.8 + */ +void +gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion, + gboolean popup_set_width) +{ + g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion)); + + popup_set_width = popup_set_width != FALSE; + + if (completion->priv->popup_set_width != popup_set_width) + { + completion->priv->popup_set_width = popup_set_width; + + g_object_notify (G_OBJECT (completion), "popup-set-width"); + } +} + +/** + * gtk_entry_completion_get_popup_set_width: + * @completion: a #GtkEntryCompletion + * + * Returns whether the completion popup window will be resized to the + * width of the entry. + * + * Return value: %TRUE if the popup window will be resized to the width of + * the entry + * + * Since: 2.8 + **/ +gboolean +gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion) +{ + g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), TRUE); + + return completion->priv->popup_set_width; +} + + #define __GTK_ENTRY_COMPLETION_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkentrycompletion.h b/gtk/gtkentrycompletion.h index f1e22ebcc7..24ce984d0d 100644 --- a/gtk/gtkentrycompletion.h +++ b/gtk/gtkentrycompletion.h @@ -107,6 +107,10 @@ gboolean gtk_entry_completion_get_inline_completion (GtkEntryComplet void gtk_entry_completion_set_popup_completion (GtkEntryCompletion *completion, gboolean popup_completion); gboolean gtk_entry_completion_get_popup_completion (GtkEntryCompletion *completion); +void gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion, + gboolean popup_set_width); +gboolean gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion); + /* convenience */ void gtk_entry_completion_set_text_column (GtkEntryCompletion *completion, -- 2.30.2